﻿// Copyright (c)  MOKEYISH. All rights reserved.
// Licensed under the MIT License, See License.txt in the project root for license information.

namespace NSQL.Expressions.Functions
{
    public class LengthFunction : BaseExpression, ILengthFunction
    {
        public IStringExpression Expr { get; }

        public LengthFunction(IValueExpression expression)
        {
            Expr = (IStringExpression) expression;
        }

        public override T Accept<T>(IExpressionVisitor<T> visitor) => visitor.Visit(this);

        public static ArithmeticExpression operator +(LengthFunction left, IIntegerExpression right)
        {
            return new ArithmeticExpression(left, right, ArithmeticOperator.Plus);
            
        }

        public static ArithmeticExpression operator +(LengthFunction left, IntegerExpression right)
        {
            return new ArithmeticExpression(left, right, ArithmeticOperator.Plus);
        }

        public static ArithmeticExpression operator +(IntegerExpression left,  LengthFunction right)
        {
            return new ArithmeticExpression(left, right, ArithmeticOperator.Plus);
        }
        
        
        public static ArithmeticExpression operator -(LengthFunction left, IIntegerExpression right)
        {
            return new ArithmeticExpression(left, right, ArithmeticOperator.Minus);
            
        }

        public static ArithmeticExpression operator -(LengthFunction left, IntegerExpression right)
        {
            return new ArithmeticExpression(left, right, ArithmeticOperator.Minus);
        }
        public static ArithmeticExpression operator -(IntegerExpression left, LengthFunction right)
        {
            return new ArithmeticExpression(left, right, ArithmeticOperator.Minus);
        }
    }
}